/*
 * bam.h
 *
 *  Created on: Aug 25, 2011
 *      Author: lindenb
 */

#ifndef BAM_H_
#define BAM_H_
#include <stdint.h>

class Reference
    {
    private:
	char* _name;
	int32_t _id;
	int32_t _len;
	Reference();
    public:
	Reference(int32_t id,const char* name,int32_t len);
	~Reference();
	int32_t id() const;
	int32_t length() const;
	const char* name() const;
    };
class BamReader;

class BamAlign
    {
    private:
	int32_t tid;
	int32_t pos;
	uint32_t bin:16, qual:8, l_qname:8;
	uint32_t flag:16, n_cigar:16;
	int32_t l_qseq;
	int32_t mtid;
	int32_t mpos;
	int32_t isize;

	int l_aux, data_len, m_data;
	uint8_t *data;

    public:
	BamAlign():data(NULL) {}
	virtual ~BamAlign(){}

    friend class BamReader;
    };

class BamReader
    {
    private:
	void* bgz;
	char* text;
	int32_t n_ref;
	Reference** references;
	BamAlign* _align;
    public:
	BamReader(const char* filename);
	virtual ~BamReader();
	virtual const BamAlign* next();
    };

#endif /* BAM_H_ */
